package com.esisa.business;

import java.util.List;

import com.esisa.dao.CompteDao;
import com.esisa.dao.TypeBetailDao;
import com.esisa.models.Compte;
import com.esisa.models.TypeBetail;

public class DefaultAdminManager implements AdminManager {

	private TypeBetailDao typeBetailDao;
	private CompteDao compteDao;
	@Override
	public boolean createTypeBetail(TypeBetail typeBetail) {
		return typeBetailDao.insert(typeBetail);
	}

	@Override
	public TypeBetail findTypeBetail(String type) {
		return typeBetailDao.select(type);
	}

	@Override
	public List<TypeBetail> findAllTypeBetail() {
		return typeBetailDao.selectAll();
	}
	@Override
	public boolean bloquerCompte(String login) {
		Compte c = compteDao.select(login);
		if(c==null)
		return false;
		c.setLocked(true);
		compteDao.update(c);
		return true;
	}
	@Override
	public boolean debloquerCompte(String login) {
		Compte c = compteDao.select(login);
		if(c==null)
		return false;
		c.setLocked(false);
		compteDao.update(c);
		return true;
	}
	public void setTypeBetailDao(TypeBetailDao typeBetailDao) {
		this.typeBetailDao = typeBetailDao;
	}

	public void setCompteDao(CompteDao compteDao) {
		this.compteDao = compteDao;
	}
	
	

}
